<?php

class side_menu
{
	var $menu_items = array();
	
	function side_menu($menu_id, $id=0, $data='')
	{
		global $lang;
		if($menu_id == 'admin')
		{
			if(  $_SESSION["valid_admin"] > 2)
			{	
				$this->menu_items[] = '<a href="admin.php?action=drivername">'. $lang['Drivers'].'</a>';
				$this->menu_items[] = '+ <a href="admin.php?action=driverlicenseupgrade">'. $lang['LicenseUpgrade'].'</a>';
				$this->menu_items[] = '+ <a href="admin.php?action=bans">'. $lang['Bans'].'</a>';
				$this->menu_items[] = '+ <a href="admin.php?action=massemail">'. $lang['AdminMassEmail'].'</a>';
				$this->menu_items[] = '';
			}
			$this->menu_items[] = '<a href="admin.php?action=games">'. $lang['Games'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = '<a href="admin.php?action=series">'. $lang['Series'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = '<a href="admin.php?action=championships">'. $lang['AdminEditChampionships'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=divisions">'. $lang['AdminEditDivisions'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=logo&mode=divisions">'. $lang['AdminEditDivisions'].' ' .$lang['AdminEditLogos'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=events">'. $lang['AdminEditEvents'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=champclass">'. $lang['AdminEditCarClass'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=champsignups">'. $lang['AdminEditChampSignUps'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=eventsignups">'. $lang['AdminEditEventSignUps'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=reservednumbers">'. $lang['AdminEditReservedNumbers'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=reserveddivisions">'. $lang['AdminEditReservedDivisions'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=honourcats">'. $lang['AdminEditHonoursCatagories'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=honourents">'. $lang['AdminEditHonoursWinners'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=judges">'. $lang['AdminEditJudges'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = '<a href="admin.php?action=tracks">'. $lang['AdminEditTracks'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = '<a href="admin.php?action=carclasses">'. $lang['AdminEditCarClass'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = '<a href="admin.php?action=cars">'. $lang['AdminEditCars'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = '<a href="admin.php?action=teams">'. $lang['AdminEditTeams'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=teammembers">'. $lang['AdminEditDrivers'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=logo&mode=teams">'. $lang['AdminEditLogos'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = '<a href="admin.php?action=partners">'. $lang['AdminEditPartners'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=logo&mode=partners">'. $lang['AdminEditLogos'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = '<a href="admin.php?action=licenses">'. $lang['AdminEditLicenses'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=banthresholds">'. $lang['BanThresholds'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = $lang['AdminEditNews'];
			$this->menu_items[] = '+ <a href="admin.php?action=newsarticles">'. $lang['AdminEditNewsArticles'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = $lang['FAQ'];
			$this->menu_items[] = '+ <a href="admin.php?action=faqcatagories">'. $lang['FAQCatagories'].'</a>';
			$this->menu_items[] = '+ <a href="admin.php?action=faqs">'. $lang['FAQQuestions'].'</a>';
		}
		else if($menu_id == 'championship')
		{
			$this->menu_items[] = $lang['information'];
			$this->menu_items[] = '+ <a href="championships.php?mode=intro&id='.$id.'">'. $lang['overview'].'</a>';
			$this->menu_items[] = '+ <a href="championships.php?mode=cars&id='.$id.'">'. $lang['cars'].'</a>';
			$this->menu_items[] = '+ <a href="championships.php?mode=calendar&id='.$id.'">'. $lang['calendar'].'</a>';
			$this->menu_items[] = '+ <a href="championships.php?mode=entrants&id='.$id.'">'. $lang['entrants'].'</a>';
			$this->menu_items[] = '';
			
			$this->menu_items[] = $lang['EventResults'];
			if($data['result_count'] > 0)
			{
				$this->menu_items[] = '+ <a href="championships.php?mode=results&id='.$id.'">'. $lang['Events'].'</a>';
				$this->menu_items[] = '+ <a href="championships.php?mode=incidents&id='.$id.'">'. $lang['Incidents'].'</a>';
			}
			$this->menu_items[] = '+ <a href="championships.php?mode=tables&id='.$id.'">'. $lang['tables'].'</a>';
			$this->menu_items[] = '+ <a href="championships.php?mode=honours&id='.$id.'">'. $lang['ChampionshipHonours'].'</a>';
			if($data['c_series'] > 0)
			{
                            $this->menu_items[] = '';
                            $this->menu_items[] = $lang['SeriesHistory'];
                            $this->menu_items[] = '+ <a href="championships.php?mode=history&type=drivers&id='.$id.'">'. $lang['Drivers'].'</a>';
                            $this->menu_items[] = '+ <a href="championships.php?mode=history&type=teams&id='.$id.'">'. $lang['Teams'].'</a>';
                            $this->menu_items[] = '+ <a href="championships.php?mode=history&type=manufacturers&id='.$id.'">'. $lang['Manufacturers'].'</a>';
			}
			
		}
		else if($menu_id == 'teams')
		{
			$this->menu_items[] = '<a href="teams.php?mode=information&id='.$id.'">'. $lang['intro'].'</a>';
		}
		else if($menu_id == 'statistics')
		{
			$this->menu_items[] = $lang['TeamDrivers'];
			$this->menu_items[] = '+ <a href="statistics.php">'. $lang['StatisticsRanking'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverchamps">'. $lang['StatisticsMostChamps'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverraces">'. $lang['StatisticsMostRaces'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverlaps">'. $lang['StatisticsMostLaps'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=drivertime">'. $lang['StatisticsMostTime'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverwins">'. $lang['StatisticsMostWins'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverpodiums">'. $lang['StatisticsMostPodiums'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverpoints">'. $lang['StatisticsMostPoints'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverpoles">'. $lang['StatisticsMostPoles'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverfastest">'. $lang['StatisticsMostFastest'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverlicense">'. $lang['StatisticsMostLicensePoints'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=driverbans">'. $lang['StatisticsBans'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = $lang['Teams'];
			$this->menu_items[] = '+ <a href="statistics.php?action=teamchamps">'. $lang['StatisticsMostChamps'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=teamraces">'. $lang['StatisticsMostRaces'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=teamwins">'. $lang['StatisticsMostWins'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=teampodiums">'. $lang['StatisticsMostPodiums'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=teampoints">'. $lang['StatisticsMostPoints'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=teampoles">'. $lang['StatisticsMostPoles'].'</a>';
			$this->menu_items[] = '+ <a href="statistics.php?action=teamfastest">'. $lang['StatisticsMostFastest'].'</a>';
		}
		else if($menu_id == 'cars')
		{
			$this->menu_items[] = '<a href="cars.php?id='.$id.'">'. $lang['intro'].'</a>';
		}
		else if($menu_id == 'users')
		{
			$this->menu_items[] = $data['user_drivername'];
			$this->menu_items[] = '+ <a href="drivers.php?mode=information&id='.$id.'">'. $lang['intro'].'</a>';
			$this->menu_items[] = '+ <a href="drivers.php?mode=license&id='.$id.'">'. $lang['License'].'</a>';
			$this->menu_items[] = '+ <a href="drivers.php?mode=incidents&id='.$id.'">'. $lang['Incidents'].'</a>';
			$this->menu_items[] = '+ <a href="drivers.php?mode=career&id='.$id.'">'. $lang['career'].'</a>';
			$this->menu_items[] = '+ <a href="drivers.php?mode=statistics&id='.$id.'">'. $lang['statistics'].'</a>';
		}
		else if($menu_id == 'usercp')
		{
			$this->menu_items[] = $lang['UserCPTeams'];
			$this->menu_items[] = '+ <a href="usercp.php?action=myteams">'. $lang['UserCPTeamsOverview'].'</a>';
			$this->menu_items[] = '+ <a href="usercp.php?action=teamadmin">'. $lang['UserCPTeamsAdmin'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = $lang['UserCPEntries'];
			$this->menu_items[] = '+ <a href="usercp.php?action=mychampionships">'. $lang['Championships'].'</a>';
			$this->menu_items[] = '+ <a href="usercp.php?action=mycurrentevents">'. $lang['EventsFuture'].'</a>';
			$this->menu_items[] = '+ <a href="usercp.php?action=mypastevents">'. $lang['EventsRecent'].'</a>';
			$this->menu_items[] = '';
			$this->menu_items[] = $lang['Incidents'];
			$this->menu_items[] = '+ <a href="usercp.php?action=myincidents">'. $lang['UserCPMyIncidents'].'</a>';
			$this->menu_items[] = '+ <a href="usercp.php?action=incidentadmin">'. $lang['TeamAdmin'].'</a>';
		}
		else if($menu_id == 'events')
		{
			$this->menu_items[] = '<a href="events.php?id='.$id.'">'. $lang['UserCPTeamsOverview'].'</a>';
			$this->menu_items[] = '<a href="events.php?mode=entrants&id='.$id.'">'. $lang['entrants'].'</a>';
			if(isset($data['result_count']) && $data['result_count'] > 0)
			{
				$this->menu_items[] = '<a href="events.php?mode=results&id='.$id.'">'. $lang['EventResults'].'</a>';
				$this->menu_items[] = '<a href="events.php?mode=incidents&id='.$id.'">'. $lang['Incidents'].'</a>';
			}
		}
	}
	
	function render()
	{
		global $skin_dir;
		$links = '';
		foreach($this->menu_items as $item)
		{
			$links = $links . $item . '<br>';
		}
		include $skin_dir . 'tpl/sidemenu.tpl';
	}
}
?>